package oopcom;

import org.omg.CORBA.PUBLIC_MEMBER;

import java.util.Scanner;

public class Person {
     //属性：描述类的特征
     public int id;
     public String name;
     public String password;
     public int age;

     //方法：执行类的操作。吃饭，睡觉，喝水
     public void sleep(){
          System.out.println("睡觉...");
     }

     public void eat(){
          sleep();
          System.out.println("吃饭..");
     }

     public void getP(){
          Scanner scanner = new Scanner(System.in);
          boolean isOk=true;
          while (isOk){
               System.out.println("请输入姓名：");
               String name = scanner.next();
               if(name.equals("n")){
                    System.out.println("退出程序");
                    isOk=false;
                    return;
               }
               System.out.println("请输入年龄：");
               int age = scanner.nextInt();
               if(age>20){
                    System.out.println(name+"的年龄为"+age+",门票的价格为：20");
               }else {
                    System.out.println(name+"的年龄为"+age+",门票免费");
               }
          }
     }

}
